<html>
<head><meta charset="utf-8"><title>checking divergence flag in coercion · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html">checking divergence flag in coercion</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196906217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196906217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196906217">(May 08 2020 at 15:02)</a>:</h4>
<p>there's this comment in <a href="https://github.com/rust-lang/rust/blob/a51e004e1bf7f9bba151dd9104a217c1ace6a0a2/src/librustc_typeck/check/demand.rs#L114-L116" title="https://github.com/rust-lang/rust/blob/a51e004e1bf7f9bba151dd9104a217c1ace6a0a2/src/librustc_typeck/check/demand.rs#L114-L116">demand.rs</a>:</p>
<div class="codehilite"><pre><span></span><code><span class="w">    </span><span class="c1">// N.B., this code relies on `self.diverges` to be accurate. In</span>
<span class="w">    </span><span class="c1">// particular, assignments to `!` will be permitted if the</span>
<span class="w">    </span><span class="c1">// diverges flag is currently &quot;always&quot;.</span>
</code></pre></div>


<p>is that actually still true? I couldn't find any reference to <code>diverges</code> in the coercion code, but maybe I'm just missing it</p>



<a name="196907188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196907188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196907188">(May 08 2020 at 15:09)</a>:</h4>
<p>hmm</p>



<a name="196907195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196907195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196907195">(May 08 2020 at 15:09)</a>:</h4>
<p>I remember adding that flag</p>



<a name="196907208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196907208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196907208">(May 08 2020 at 15:09)</a>:</h4>
<p>but I could imagine it became outdated</p>



<a name="196907363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196907363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196907363">(May 08 2020 at 15:10)</a>:</h4>
<p>I feel like we may have opted against the approach we were trying there</p>



<a name="196907376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196907376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196907376">(May 08 2020 at 15:10)</a>:</h4>
<p>sigh, the long and tortured history of <code>!</code></p>



<a name="196911577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911577">(May 08 2020 at 15:40)</a>:</h4>
<p>I mean, the flag is being checked elsewhere -- <code>check_block_with_expected</code> handles it. So maybe that's where those cases are handled now</p>



<a name="196911601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911601">(May 08 2020 at 15:40)</a>:</h4>
<p>hmm</p>



<a name="196911622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911622">(May 08 2020 at 15:40)</a>:</h4>
<p>that sounds right</p>



<a name="196911644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911644">(May 08 2020 at 15:41)</a>:</h4>
<p>sorry, I've not had a sec to grep the codebase myself</p>



<a name="196911707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911707">(May 08 2020 at 15:41)</a>:</h4>
<p>I do remember there being some logic like "if the block diverges, then we ignore the type of the tail expression, but else we don't"</p>



<a name="196911732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911732">(May 08 2020 at 15:41)</a>:</h4>
<p>in order to accommodate</p>
<div class="codehilite"><pre><span></span><code><span class="p">{</span><span class="w"> </span><span class="n">panic</span><span class="o">!</span><span class="p">();</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>and not give type errors</p>



<a name="196911746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911746">(May 08 2020 at 15:42)</a>:</h4>
<p>or at least, if the block diverges and has an implicit <code>()</code> tail</p>



<a name="196911831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911831">(May 08 2020 at 15:42)</a>:</h4>
<p>yeah, that's in <code>check_block_with_expected</code></p>



<a name="196911856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911856">(May 08 2020 at 15:42)</a>:</h4>
<p>I <em>believe</em> this is what the comment was referring to</p>



<a name="196911872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911872">(May 08 2020 at 15:42)</a>:</h4>
<p>I think we <em>used</em> to maybe have more general logic there</p>



<a name="196911885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911885">(May 08 2020 at 15:42)</a>:</h4>
<p>I was just worried I was missing some edge case ;)</p>



<a name="196911889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911889">(May 08 2020 at 15:42)</a>:</h4>
<p>er, sorry</p>



<a name="196911914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911914">(May 08 2020 at 15:43)</a>:</h4>
<p>I believe the comment may have been referring to some <em>older</em> logic that I stripped down</p>



<a name="196911950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196911950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196911950">(May 08 2020 at 15:43)</a>:</h4>
<p>I could do a bit of digging to find the issues where we dug into this... but I won't unels you really need it</p>



<a name="196912096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/checking%20divergence%20flag%20in%20coercion/near/196912096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/checking.20divergence.20flag.20in.20coercion.html#196912096">(May 08 2020 at 15:44)</a>:</h4>
<p>I think that won't be necessary :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>